Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE/HCMPRE-1713: PopInbox and filtering integration #2108

Merged
merged 10 commits into from
Jan 9, 2025

Conversation

abishekTa-egov
Copy link
Contributor

@abishekTa-egov abishekTa-egov commented Jan 6, 2025

FEATURE/HCMPRE-1713: PlanIbox and filtering integration

Summary by CodeRabbit

  • New Features

    • Enhanced filtering capabilities for plans by including facility ID as a search criterion.
    • Added facility ID as a new filter option across multiple components.
  • Bug Fixes

    • Improved state management for filter selections.
    • Corrected handling of filter values and dropdown selections.
  • Refactor

    • Updated state initialization and management in filter-related components.
    • Standardized filter handling across different inbox views.
    • Introduced new CSS class for improved styling of filter names.
    • Updated CSS stylesheet versions for health UI components.

@abishekTa-egov abishekTa-egov requested a review from a team as a code owner January 6, 2025 12:21
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

📝 Walkthrough

Walkthrough

This pull request introduces modifications to several files within the microplan module: InboxFilterWrapper.js, PlanInbox.js, PopInbox.js, and others. The changes primarily focus on enhancing filter management by introducing a new facilityId property and updating state handling mechanisms across components. The modifications standardize filter state initialization, improve API request configurations, and adjust component rendering to accommodate new facility-related filtering capabilities, including updates to CSS styles and links.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js - Added Fragment import
- Updated filterValues initial state to include facilityID
- Modified default selection and filter application logic for facilityId
- Added conditional rendering for facility-related dropdowns
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js - Added facilityId to selectedFilter state
- Included facilityId in API request bodies for plan search
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js - Updated selectedFilter state initialization
- Modified conditional checks and filter management logic
- Adjusted component rendering to use status property
health/micro-ui/web/micro-ui-internals/example/public/index.html - Updated CSS link version from 0.2.35 to 0.2.36
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss - Added new CSS class .custom-filter-names with specified styles
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js - Removed filtering logic for employees with null userServiceUuid
- Updated handleBoundaryChange function for state consistency
health/micro-ui/web/public/index.html - Updated CSS stylesheet version from 0.2.35 to 0.2.36

Sequence Diagram

sequenceDiagram
    participant User
    participant InboxFilterWrapper
    participant PlanInbox
    participant API

    User->>InboxFilterWrapper: Select Facility Filter
    InboxFilterWrapper->>PlanInbox: Update selectedFilter
    PlanInbox->>API: Search Plans with facilityId
    API-->>PlanInbox: Return Filtered Results
    PlanInbox-->>User: Display Filtered Plans
Loading

Possibly related PRs

Suggested reviewers

  • nipunarora-eGov
  • Swathi-eGov

Poem

🐰 A Rabbit's Filter Tale 🔍

In microplan's digital domain,
Where filters dance and data reign,
A new facilityId takes flight,
Bringing searches crisp and bright!

Code hops, state shifts with glee! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 602bb0c and ec35f8f.

📒 Files selected for processing (1)
  • health/micro-ui/web/public/index.html (1 hunks)
🔇 Additional comments (3)
health/micro-ui/web/public/index.html (3)

11-11: Verify the beta version update and its stability

The component CSS is using a beta version (0.0.2-beta.44). While this update might be needed for the new filtering features, using beta versions in production could lead to instability.

Please ensure:

  1. This version is compatible with the new filtering features
  2. No regressions in existing UI components
  3. Consider using a stable version if available

11-13: Resolve component CSS version inconsistency across files

While the health CSS version (0.2.36) is consistent, there's a discrepancy in the component CSS versions between the two index.html files:

Please align these versions to prevent potential styling inconsistencies.


13-13: Verify the health CSS update changelog

The health CSS has been updated to version 0.2.36. This update might include new styles for the PlanInbox and filtering integration.

Run this script to check the changelog and verify the update:

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@abishekTa-egov abishekTa-egov changed the title FEATURE/HCMPRE-1713: PlanIbox and filtering integration FEATURE/HCMPRE-1713: PopInbox and filtering integration Jan 6, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7220828 and 76b3134.

📒 Files selected for processing (3)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (6 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (4 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (14 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (1)

Pattern **/*.js: check

📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 74-74: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 77-77: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js

[error] 272-272: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

🔇 Additional comments (19)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

179-179: 🧹 Nitpick (assertive)

Confirm existence of facilityId.id.

When you pass facilityId.id into the request, ensure it won't raise a runtime error. For instance, if facilityId is accidentally set to a non-object, or if .id is missing. Add an additional safety check or strong type validation.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Line range hint 163-230: Looks good overall.

The conditional rendering and usage of <Fragment> to group extra filters appear consistent and clear. The references to the new facilityId property, state handling, and dropdown usage are aligned with the updated logic.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (17)

29-29: Initialize filter state with an object.
Using an object for the default state is consistent with subsequent logic that relies on object properties. No concerns here.


284-284: Conditional check for status.
Comparing state.state to selectedFilter?.status is straightforward and correct for verifying a matching workflow state.


296-296: No concerns with useEffect dependencies.
Including selectedFilter?.status in the dependency array ensures the effect re-runs whenever the status changes.


427-429: State setter does nothing.
Spreading prev without adding or removing properties leaves the state unchanged. Verify if this is intentional or if additional updates are needed.


436-436: Assigning count based on status.
This line logically assigns the count for the current status; no specific concerns.


447-447: Appropriate effect dependencies.
No issues observed; the dependency array is accurate for re-fetch logic.


450-450: Clear condition for "VALIDATED" status.
The logic is consistent with your workflow. No issues.


462-462: Dependency array includes status.
Ensures consistent re-render whenever status changes. Looks good.


464-464: Filter handler.
This new function centralizes filter logic nicely. No issues.


472-477: Merging filter values.
Using the spread operator is a clean way to merge incoming filter properties with existing ones.


643-643: isEstimate prop usage.
No concerns or errors. This boolean prop is straightforward.


647-647: defaultValue assignment.
Providing selectedFilter here ensures filter UI stays in sync with state. No issues.


496-498: Guard against empty activeFilter.
If activeFilter is empty, Object.entries(activeFilter)?.[0]?.[0] might be undefined. Consider a fallback to avoid unexpected state.


567-567: Validation action condition is clear.
Checking if status is "PENDING_FOR_VALIDATION" matches expected workflow. No points of concern.


570-570: Approval action condition is consistent.
No issues with verifying "PENDING_FOR_APPROVAL" before allowing "APPROVE" or "ROOT_APPROVE".


573-573: Send-back action condition is consistent.
No concerns here; logic is straightforward.


772-772: Conditional styling based on status.
Applying different heights for "VALIDATED" is minor but acceptable.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Line range hint 89-126: Improve API configuration and error handling.

  1. Consider using a finite cache time to prevent stale data.
  2. Implement error handling for the API call.
 const planFacilitySearchConfig = {
   // ... existing config
   config: {
     enabled: true,
     select: (data) => {
+      if (!data) {
+        console.error('No data received from facility search');
+        return [];
+      }
       if (!data?.PlanFacility || !Array.isArray(data.PlanFacility)) return [];
       
       const facilityOptions = data.PlanFacility.map((facility) => ({
         code: facility.facilityName,
         id: facility.facilityId
       }));
       
       return facilityOptions;
     },
-    cacheTime: Infinity
+    cacheTime: 5 * 60 * 1000 // 5 minutes
   }  
 };

+if (planFacilityerror) {
+  console.error('Error fetching facility data:', planFacilityerror);
+  // Consider showing an error message to the user
+}
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Line range hint 1-1199: Consider splitting the component for better maintainability.

The PlanInbox component has grown quite large and handles multiple responsibilities. Consider breaking it down into smaller, focused components:

  1. Filter management
  2. Table management
  3. Workflow actions
  4. API integration layer

This will improve maintainability and testability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76b3134 and da7f973.

⛔ Files ignored due to path filters (1)
  • health/micro-ui/web/micro-ui-internals/packages/css/package.json is excluded by !**/*.json
📒 Files selected for processing (6)
  • health/micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (8 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js (0 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (4 hunks)
  • health/micro-ui/web/public/index.html (1 hunks)
💤 Files with no reviewable changes (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Pattern **/*.js: check

📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 208-211: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 205-205: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

🔇 Additional comments (9)
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1)

541-542: LGTM!

The syntax error has been fixed by properly closing the .gap-between-dropdowns class with a closing brace.

health/micro-ui/web/micro-ui-internals/example/public/index.html (1)

15-15: Verify the updated CSS version exists.

The CSS version has been updated from 0.2.33 to 0.2.34. Let's verify this version exists and contains the required PlanIbox and filtering styles.

✅ Verification successful

CSS version 0.2.34 is valid and contains the required styles

The updated version exists and includes comprehensive styling for microplan components and filtering functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and contents of the updated CSS version

# Check if the new version exists on unpkg
curl -s -o /dev/null -w "%{http_code}" https://unpkg.com/@egovernments/[email protected]/dist/index.css

# Check if there are any PlanIbox or filtering related styles
curl -s https://unpkg.com/@egovernments/[email protected]/dist/index.css | grep -i "plan\|filter"

Length of output: 36606

health/micro-ui/web/public/index.html (1)

13-13: LGTM! Version update is consistent.

The CSS version update matches the change in the example template, maintaining consistency across the application.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (3)

14-14: Unify naming convention for facilityId.

The state initialization uses facilityID (capital D) while the rest of the code references facilityId. This discrepancy can cause confusion or bugs.


19-27: LGTM! Default options handling is well implemented.

The code properly handles both null and non-null values while maintaining immutability.


215-215: LGTM! Consistent usage of optionsKey.

The code correctly uses optionsKey="code" for Dropdown components and maintains "name" for RadioButtons, following the established patterns.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (3)

36-36: LGTM! State initialization looks good.

The facilityName property is properly initialized as null in the selectedFilter state object.


179-179: LGTM! API integration is consistent.

The facilityName filter is properly integrated into both search APIs using the spread operator with null checks.

Also applies to: 220-221


888-888: Verify the implementation of isEstimate prop.

The isEstimate prop is passed to InboxFilterWrapper, but its implementation needs verification.

Run this script to check the prop's usage in the InboxFilterWrapper component:

✅ Verification successful

✓ The isEstimate prop is properly implemented

The prop is correctly used to toggle the village road condition filter in InboxFilterWrapper, with consistent usage across PlanInbox (true) and PopInbox (false) components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for isEstimate prop usage in InboxFilterWrapper
ast-grep --pattern 'const $_ = $props.isEstimate' && \
ast-grep --pattern 'isEstimate={$_}' && \
ast-grep --pattern 'if ($props.isEstimate) {
  $$$
}'

Length of output: 146


Script:

#!/bin/bash
# Find InboxFilterWrapper component file
fd InboxFilterWrapper

# Search for any usage of isEstimate in the codebase
rg "isEstimate" -A 3 -B 3

# Look for prop types or interface definitions
ast-grep --pattern 'interface $_ {
  isEstimate$_?: $_
  $$$
}'

Length of output: 3176

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (2)

14-14: 🧹 Nitpick (assertive)

Maintain consistent naming convention for facility identifier

The state initialization uses facilityName while previous code used facilityId. Consider aligning the naming convention across the codebase.

-{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityName:null }
+{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null, facilityId: null }

205-218: 🛠️ Refactor suggestion

Fix React key, parsing, and translation key issues

Multiple improvements needed in the security questions mapping:

  1. Add key prop for React list rendering
  2. Use Number.parseInt for consistency
  3. Use underscore instead of space in translation key
- const questionNumber = parseInt(item.id, 10);
+ const questionNumber = Number.parseInt(item.id, 10);

  return (
    <LabelFieldPair
+     key={`security-question-${questionNumber}`}
      vertical
      style={{ paddingBottom: isLastElement ? "1rem" : "0" }}
    >
-     <div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index+1}`)}</div>
+     <div className="custom-filter-names">{t(`MP_SECURITY_QUESTION_${index + 1}`)}</div>
🧰 Tools
🪛 Biome (1.9.4)

[error] 208-211: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 205-205: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da7f973 and c48d451.

📒 Files selected for processing (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (9 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Pattern **/*.js: check

📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 208-211: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 205-205: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

🔇 Additional comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (4)

1-1: LGTM: Fragment import added correctly

The Fragment import is properly added and used later in the code for wrapping multiple elements.


Line range hint 110-119: Verify infinite cache time strategy

While the facility mapping logic is correct, setting cacheTime to Infinity might prevent updates to facility data from being reflected. Consider using a more appropriate cache duration based on how frequently facility data changes.


157-158: LGTM: Fragment wrapper properly implemented

The Fragment is correctly used to wrap estimate-specific filters and properly conditioned with props.isEstimate.

Also applies to: 224-225


160-160: LGTM: Consistent styling approach for filter labels

The switch to div elements with custom-filter-names class provides better styling control and maintains consistency across all filter labels.

Also applies to: 172-172, 184-184

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 8, 2025
Copy link
Contributor

@nipunarora-eGov nipunarora-eGov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check comments

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
health/micro-ui/web/micro-ui-internals/example/public/index.html (1)

15-15: 🧹 Nitpick (assertive)

Consider hosting CSS files locally for better reliability.

While using unpkg CDN is convenient, consider hosting these CSS files locally to:

  • Reduce dependency on external services
  • Improve load times
  • Ensure version consistency
  • Better control over asset availability
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c48d451 and 602bb0c.

⛔ Files ignored due to path filters (1)
  • health/micro-ui/web/micro-ui-internals/packages/css/package.json is excluded by !**/*.json
📒 Files selected for processing (5)
  • health/micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (8 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (4 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (14 hunks)
  • health/micro-ui/web/public/index.html (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Pattern **/*.js: check

📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js

[error] 272-272: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 74-74: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 77-77: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 215-218: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 212-212: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

🔇 Additional comments (13)
health/micro-ui/web/micro-ui-internals/example/public/index.html (1)

15-15: Verify version consistency with package dependencies

The CSS version has been updated to 0.2.36. Please ensure this version is consistent with the package.json dependencies.

✅ Verification successful

Version consistency verified ✓

The CSS version 0.2.36 used in the CDN URL matches exactly with the package version in health/micro-ui/web/micro-ui-internals/packages/css/package.json.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the version in package.json matches the CDN version
fd package.json | xargs cat | jq -r '.dependencies["@egovernments/digit-ui-health-css"]'

Length of output: 280


Script:

#!/bin/bash
# Search for any mention of digit-ui-health-css in package.json files
rg -A 5 -B 5 "digit-ui-health-css" $(fd package.json)

Length of output: 2819

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (7)

14-14: Maintain consistent naming for facilityId.

The state initialization uses facilityID (capital D) while the rest of the code references facilityId. This inconsistency can lead to bugs.

Apply this diff to maintain consistency:

- { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityID:null }
+ { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null, facilityId: null }

19-29: LGTM! Clean implementation of facilityId default value handling.

The special case handling for facilityId is well-implemented, maintaining the code's structure while adding the new functionality.


37-39: LGTM! Clean implementation of facilityId state update.

The useEffect hook correctly handles the facilityId case by only setting the code without the name property.


74-77: Use Object.hasOwn() for safer property checks.

Using hasOwnProperty directly on objects can be unsafe if the object's prototype is altered. Use Object.hasOwn() instead.

Apply this diff to improve security:

-if(filterValues[key] && typeof filterValues[key] === 'object' && String(key)==='facilityId' &&filterValues[key].hasOwnProperty('code') ){
+if(filterValues[key] && typeof filterValues[key] === 'object' && String(key)==='facilityId' && Object.hasOwn(filterValues[key], 'code')) {
   filtersToApply[key] = filterValues[key]
 }
-else if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('code')) {
+else if (filterValues[key] && typeof filterValues[key] === 'object' && Object.hasOwn(filterValues[key], 'code')) {
   filtersToApply[key] = filterValues[key].code;
 }
🧰 Tools
🪛 Biome (1.9.4)

[error] 74-74: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


[error] 77-77: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


191-199: Add key prop to LabelFieldPair.

React requires a key prop when rendering elements in a list to help with efficient updates.

Apply this diff:

-<LabelFieldPair vertical>
+<LabelFieldPair vertical key="facility-filter">
   <div className="custom-filter-names">{t("MP_FILTER_FACILITY")}</div>           
   <Dropdown
     option={planFacility}
     optionKey={"code"}
     selected={filterValues["facilityId"] || defaultSelectedOptions?.facilityId  }
     select={(value) => handleDropdownChange("facilityId", value)}
     t={t}
     disabled={false}
   />
 </LabelFieldPair>   

212-225: Improve security questions implementation.

  1. Use Number.parseInt instead of global parseInt for consistency with ES2015.
  2. Avoid spaces in translation keys.

Apply this diff:

-const questionNumber = parseInt(item.id, 10); 
+const questionNumber = Number.parseInt(item.id, 10);

-<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index + 1}`)}</div>             
+<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION_${index + 1}`)}</div>             
🧰 Tools
🪛 Biome (1.9.4)

[error] 215-218: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 212-212: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)


Line range hint 164-232: LGTM! Clean implementation of conditional rendering.

The isPlanInbox prop is used correctly to conditionally render the filter options.

🧰 Tools
🪛 Biome (1.9.4)

[error] 215-218: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 212-212: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (2)

29-29: LGTM! Clean state initialization.

The initial state is well-structured with a meaningful default value for the status.


472-477: LGTM! Clean filter state update.

The filter state update correctly preserves existing state while applying new values.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (3)

36-36: LGTM! Clean state initialization with facilityId.

The initial state correctly includes facilityId with a null value.


179-180: LGTM! Consistent facility filter implementation.

The facility-based filtering is implemented consistently across both API calls.

Also applies to: 220-221


Line range hint 888-892: LGTM! Correct usage of isPlanInbox prop.

The InboxFilterWrapper is correctly configured with the isPlanInbox prop.

health/micro-ui/web/public/index.html Show resolved Hide resolved
@nipunarora-eGov nipunarora-eGov merged commit ea55874 into console Jan 9, 2025
4 checks passed
@nipunarora-eGov nipunarora-eGov deleted the FEATURE/HCMPRE-1713 branch January 9, 2025 05:47
nipunarora-eGov pushed a commit that referenced this pull request Jan 15, 2025
* PopInbox and facilityId search in planInbox

* Localization

* Chages to CSS and removing filter

* Changes to facility filter and security Question

* css package update

* facilityId removed

* Resolved comments, made payload to facilityId

* component package update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants